package com.Jano.service.Impl;

import com.Jano.dao.Impl.QuestionDaoImpl;
import com.Jano.dao.QuestionDao;
import com.Jano.entity.Question;
import com.Jano.exception.BusinessException;
import com.Jano.service.QuestionService;
import org.apache.commons.lang3.StringUtils;

import java.util.List;

/**
 * description: QuestionServiceImpl <br>
 * date: 2022/6/6 6:07 PM <br>
 * author: zoumaoji <br>
 * version: 1.0 <br>
 */
public class QuestionServiceImpl extends AbstractBaseServiceImpl implements QuestionService {
    QuestionDao questionDao =new QuestionDaoImpl();

    @Override
    public void createQuestion(int questionnaireId, String content) {
        if (StringUtils.isBlank(content)) {
            throw new BusinessException("问题内容不能为空");
        }
        questionDao.createQuestion(questionnaireId,content);
    }

    @Override
    public List<Question> getAllQuestionByQuestionnaireId(int questionnaireId) {
        return questionDao.selectQuestionsByQuestionnaireId(questionnaireId);
    }

    @Override
    public Question getQuestionByQuestionnaireIdAndContent(int questionnaireId, String content) {
        return questionDao.selectQuestionByQuestionnaireIdAndContent(questionnaireId,content);
    }
}
